package com.chance.cc.crawler.prod.command.trigger.domain.news.wangyi;

import com.chance.cc.crawler.core.CrawlerJob;
import com.chance.cc.crawler.meta.core.bean.CrawlerMetaConstant;
import com.chance.cc.crawler.prod.command.job.domain.news.wangyi.WYCommonScript;
import com.chance.cc.crawler.prod.command.job.domain.news.wangyi.realtime.WYRealtimeCrawlerSchedulerJob;
import com.chance.cc.crawler.prod.command.job.domain.news.wangyi.trace.WYAdTraceCrawlerSchedulerJob;
import com.chance.cc.crawler.prod.command.job.domain.news.wangyi.trace.WYCommentTraceCrawlerSchedulerJob;
import com.chance.cc.crawler.prod.command.job.domain.news.wangyi.trace.WYTraceCrawlerSchedulerJob;
import com.chance.cc.crawler.prod.command.trigger.CommonCrawlerSchedulerTrigger;

/**
 * @author lt
 * @version 1.0
 * @date 2021-04-10 15:09:29
 * @email okprog@sina.com
 */
public class WYCommonCrawlerSchedulerTrigger extends CommonCrawlerSchedulerTrigger {

    public static void main(String[] args) {
        publishWYRealtimeScheduleTriggerInfo();

        publishWYTraceScheduleTriggerInfo();

        publishWYCommentTraceScheduleTriggerInfo();

        publishTraceScheduleJob(WYAdTraceCrawlerSchedulerJob.crawlerScheduler());
//        publishSimpleScheduleJob(WYAdTraceCrawlerSchedulerJob.crawlerScheduler());
    }

    public static void publishWYRealtimeScheduleTriggerInfo(){
        CrawlerJob crawlerJob = WYRealtimeCrawlerSchedulerJob.crawlerScheduler();
        metaServiceCommand_17.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                WYCommonScript.domain,
                CrawlerMetaConstant.ScheduleJobTrigger_Cron,
                "0 0/10 * * * ?",
                "网易新闻实时采集任务，每十分钟采集一次");
    }

    public static void publishWYTraceScheduleTriggerInfo(){
        CrawlerJob crawlerJob = WYTraceCrawlerSchedulerJob.crawlerScheduler();
        metaServiceCommand_17.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                WYCommonScript.domain,
                CrawlerMetaConstant.ScheduleJobTrigger_Cron,
                "0 30 0 * * ?",
                "网易新闻追溯7日评论采集任务，每天采集一次");
    }

    public static void publishWYCommentTraceScheduleTriggerInfo(){
        CrawlerJob crawlerJob = WYCommentTraceCrawlerSchedulerJob.crawlerScheduler();
        metaServiceCommand_17.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                WYCommonScript.domain,
                CrawlerMetaConstant.ScheduleJobTrigger_Cron,
                "0 0 * * * ?",
                "网易新闻追溯当日评论采集任务，每小时采集一次");
    }

    public static void publishTraceScheduleJob(CrawlerJob crawlerJob){
        metaServiceCommand_17.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                WYCommonScript.domain,
                CrawlerMetaConstant.ScheduleJobTrigger_Cron,
                "0 30 1 * * ?",
                "网易新闻追溯7日采集任务，每天采集一次");
    }

    public static void publishSimpleScheduleJob(CrawlerJob crawlerJob){
        metaServiceCommand_17.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                WYCommonScript.domain,
                CrawlerMetaConstant.ScheduleJobTrigger_Simple,
                "",
                "网易新闻临时采集任务，采集一次");
    }
}
